home *** CD-ROM | disk | FTP | other *** search
- /* Aladdin IMid
-
- Raymond Lau 93.05.11
-
- revised 94.03.14 (jam) to use new packages parameter
- revised 94.05.03 (rmt) added "after" parameter, took into account
- Think C 6.0's stricter type checking, and added
- some additional comments.
-
-
- This IMID does the following.
-
- If folder mgr. does not exist:
-
- Aladdin [fldr] --> Always in "Extensions" in System
- Files of type 'appe' --> Always in "Extensions" in System
- Files of type 'thng' --> Always in "Extensions" in System
- Files of type 'Pref' and 'pref' --> Always in "Preferences" in System
- */
-
-
- #include <MacHeaders>
- #include <Folders.h>
- #include <GestaltEqu.h>
- #include <SetUpA4.h>
-
-
- void GetSysVolDir(short *vol,long *dir)
- {
- HParamBlockRec MyHFB;
-
- if (HFS < 0) {
- *vol = BootDrive;
- *dir = 2;
- return;
- }
-
- GetVRefNum(SysMap,vol);
-
- MyHFB.volumeParam.ioNamePtr = 0;
- MyHFB.volumeParam.ioVRefNum = *vol;
- MyHFB.volumeParam.ioVolIndex = 0;
- PBHGetVInfo(&MyHFB,FALSE);
-
- *dir = MyHFB.volumeParam.ioVFndrInfo[0];
- }
-
-
- short FindFolderInSystem(unsigned char *name,short *vol,long *dir)
- {
- short sysvol;
- long sysdir;
- HParamBlockRec HRec;
-
- GetSysVolDir(&sysvol,&sysdir);
-
- HRec.ioParam.ioNamePtr = (StringPtr)name;
- HRec.ioParam.ioVRefNum = sysvol;
- HRec.fileParam.ioDirID = sysdir;
- HRec.fileParam.ioFDirIndex = 0;
- if(!PBGetCatInfoSync((CInfoPBPtr)&HRec)) {
-
- if(!(HRec.fileParam.ioFlAttrib & 0x10)) { // not folder
- return TRUE;
- }
- *vol = sysvol;
- *dir = HRec.fileParam.ioDirID;
-
- return FALSE;
- }
-
- HRec.ioParam.ioNamePtr = (StringPtr)name;
- HRec.ioParam.ioVRefNum = sysvol;
- HRec.fileParam.ioDirID = sysdir;
- if(PBDirCreateSync(&HRec)) {
- return TRUE;
- }
-
- *vol = sysvol;
- *dir = HRec.fileParam.ioDirID;
-
- return FALSE;
- }
-
- pascal short main(short userVol,long userDir,
- short *destVol,long *destDir,
- short isFolder,
- char *name,
- unsigned long creationDate,
- unsigned long modificationDate,
- OSType type,OSType creator,
- unsigned short packages,
- short after)
- {
- long gest;
- static short thePass = 0 ;
- short result = 0;
-
- RememberA0();
- SetUpA4();
-
- // This makes sense only before we install, so we first check when our
- // IMid is being called: before or after installation.
-
- if ( !after )
- {
- // Was InstallerMaker able to use System 7 Folder Manager calls?
- if(Gestalt(gestaltFindFolderAttr,&gest) ||
- !(gest & 1L<<gestaltFindFolderPresent)) {
-
- // We're running under System 6, so we need to redirect some
- // items into the Aladdin folder under a created Extensions folder
- if(isFolder) {
- if(EqualString( (StringPtr) name,"\pAladdin",FALSE,TRUE)) {
- if(FindFolderInSystem("\pExtensions",destVol,destDir))
- result = 2;
- }
- } else {
- if(type == 'appe' || type == 'thng') {
- if(FindFolderInSystem("\pExtensions",destVol,destDir))
- result = 2;
- } else if(type == 'Pref' || type == 'pref') {
- if(FindFolderInSystem("\pPreferences",destVol,destDir))
- result = 2;
- }
- }
-
- }
- }
-
- RestoreA4();
- return result;
- }
-